package com.bubblegumproject.ogo.swing.events;

import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

/**
 * Condition triggered when a JMenuItem is clicked.
 *
 * @author Azubuko Obele (buko.obele@gmail.com)
 */
public class MenuItemClickedCondition extends AbstractCondition {

    public MenuItemClickedCondition(JMenuItem menuItem) {
        assert(menuItem != null);
        menuItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                occured();
            }
        });
    }

    public static MenuItemClickedCondition MenuItemClicked(JMenuItem menuItem) {
        return new MenuItemClickedCondition(menuItem);
    }
}
